import React, { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { getChannel } from '../../store/actions/channel'
import request from '../../utils/request'

// 加载频道的数据（把频道的数据存储到 Redux），但凡对 Redux 的操作就是那 4 个文件
export default function Channel() {
  const [list, setList] = useState([])
  useEffect(() => {
    const getList = async () => {
      const {
        data: {
          data: { channels },
        },
      } = await request.get('/channels')
      setList(channels)
    }
    getList()
  }, [])
  return (
    <ul className='catagtory'>
      {list.map((item) => (
        <li key={item.id} className='select'>
          {item.name}
        </li>
      ))}
    </ul>
  )
}
